package com.rfsp.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

@Configuration
public class SessionConfig {

    @Value("${server.servlet.session.timeout}")
    int timeOut;
    /**
     * 设置热session cookie name 以及子域共享
     *
     * @return
     */
    @Bean
    public CookieSerializer cookieSerializer() {
        DefaultCookieSerializer serializer = new DefaultCookieSerializer();

//        serializer.setDomainName(AppConfig.domain_name);
        serializer.setCookieName(AppConfig.cookie_name);//crcrfsp_jssid
        serializer.setCookiePath(AppConfig.cookie_path);
//		serializer.setCookieMaxAge(timeOut);
//		serializer.setSameSite("Lax");  // 设置SameSite属性
        serializer.setUseHttpOnlyCookie(true);
        serializer.setUseBase64Encoding(true);
//        serializer.setUseSecureCookie(true);
        //serializer.setDomainNamePattern("^.+?\\.(\\w+\\.[a-z]+)$");
        return serializer;
    }
    
}
